﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Common
{
    [XmlRoot("Rule", IsNullable = false, Namespace = "")]
    public class Rule
    {
        [XmlIgnore()]
        public static readonly string Title = "Title", Summary = "Summary", Story = "Story", Talkback = "Talkback",
            Datetime = "Datetime", Identification = "Identification";
        public string Name;
        public ExtractionDepth Depth;
        public string PropertyName, AttributeName, AttributeValue;
        public bool PartialValueMatch;
        public List<Attribute> Attributes;
        public List<Rule> Rules;
        public List<Rule> Exclusions; //Descendant tags to ignore.

        private void Init(string propertyName, string attributeName, string attributeValue, ExtractionDepth depth, bool partialValueMatch)
        {
            Name = "Rule";
            PropertyName = propertyName;
            AttributeName = attributeName;
            AttributeValue = attributeValue;
            Depth = depth;
            PartialValueMatch = partialValueMatch;
			Rules = new List<Rule>();
			Attributes = new List<Attribute>();
			Exclusions = new List<Rule>();
        }

        public Rule(string propertyName, string attributeName, string attributeValue, ExtractionDepth depth, bool partialValueMatch)
        {
            Init(propertyName, attributeName, attributeValue, depth, partialValueMatch);
        }
        public Rule(string propertyName, string attributeName, string attributeValue)
        {
            Init(propertyName, attributeName, attributeValue, ExtractionDepth.None, false);
        }
        public Rule()
        {
            Init("", "", "", ExtractionDepth.None, false);
        }
    }

    public enum ExtractionDepth { None, One, Two }
}
